<?php

class ContentController extends Zend_Controller_Action  
{	
    public function indexAction()
    {
		/*$service = new CategoryService();
		$data = $service->buildQueryData();
    	
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,5);*/
    }
    
    public function listAction()
    {
    	$service = new ContentService();
    	$data = $service->getLibrary();
    	
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,5);
		
    }
    
	public function eventAction()
    {
    	$service = new ContentService();
    	$data = $service->getEvents();
    	
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,5);
		
    }
    
    public function detailAction()
    {
    	//get detail of content
    	$id = $this->_getParam("id");
    	$service = new ContentService();
    	$content = $service->load($id);
    	if(empty($content->body))
    	{
    		$this->_redirect("/index/index");
    	}
    	$this->view->content = $content;
    	
    	
    	//cac bai viet khac
    	$data = $service->getLibrary();
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,20);
    	
    	//increase hit count
//    	$content->hits += 1;
//    	$service->save($content);
    }
    
	public function detailEventAction()
    {
    	//get detail of content
    	$id = $this->_getParam("id");
    	$service = new ContentService();
    	$content = $service->load($id);
    	if(empty($content->body))
    	{
    		$this->_redirect("/index/index");
    	}
    	$this->view->content = $content;
    	
    	
    	//cac bai viet khac
    	$data = $service->getEvents();
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,20);
    	
    	//increase hit count
//    	$content->hits += 1;
//    	$service->save($content);
    }


}

